<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue初体验</title>
</head>

<body>
  <!-- 创建一个容器 -->
  <div id="app">
    <button @click="count--">--</button>
    <h1>{{ count }}</h1>
    <button @click="count++">++</button>
  </div>

  <script src="./js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        count: 100
      },

      // 1. 创建阶段
      beforeCreate() {
        console.log('beforeCreate')
      },

      created() {
        // 初始化操作, 数据请求
        console.log('created')
      },

      // 2. 挂载阶段
      beforeMount() {
        console.log('beforeMount')
      },

      mounted() {
        // 挂载完成, 获取元素, 绑定事件
        console.log('mounted')
      },

      // 3. 更新阶段
      beforeUpdate() {
        console.log('beforeUpdate')
      },

      updated() {
        console.log('updated')
      },


      // 4. 销毁阶段
      beforeDestroy() {
        // 销毁操作, 移除定时器, 移除事件
        console.log('beforeDestroy')
      },

      destroyed() {
        console.log('destroyed')
      },
    })
  </script>
</body>

</html>